//
//  AttentionCell.m
//  HubeiHotel
//
//  Created by LiBenCan on 17/11/22.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "AttentionCell.h"
@interface AttentionCell ()
@property (nonatomic,strong)UIImageView *headerImageV;//头像
@property (nonatomic,strong)UILabel *nameLab;//名称
@property (nonatomic,strong)UILabel *lineLab;//画线
@end
@implementation AttentionCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {//先调用父类
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self CreatUI];
    }
    return self;
}
-(void)CreatUI
{
    if (!_nameLab) {
        
        //头像
        _headerImageV = [UIImageView new];
        [self.contentView addSubview:_headerImageV];
        [_headerImageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15 * screenW_6);
            make.top.equalTo(self.contentView).offset(15*screenW_6);
            make.width.equalTo(@(40*screenW_6));
            make.height.equalTo(@(40*screenW_6));
        }];
        _headerImageV.clipsToBounds = YES;
        _headerImageV.contentMode = UIViewContentModeScaleAspectFill;
        
        //关注按钮
        _GuanZLab = [[CanLab alloc]initWithFrame:CGRectZero textAligment:1 font:13*screenW_6 textColor:@"FF6900" text:@"取关"];
        [self.contentView addSubview:_GuanZLab];
        [_GuanZLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-15 * screenW_6);
            make.top.equalTo(self.contentView).offset(22.5*screenW_6);
            make.width.equalTo(@(53*screenW_6));
            make.height.equalTo(@(25*screenW_6));
        }];
        [_GuanZLab.layer setCornerRadius:5*screenW_6];
        _GuanZLab.layer.masksToBounds = YES;
        _GuanZLab.layer.borderWidth = 1;
        _GuanZLab.layer.borderColor = [[UIColor colorWithHexString:@"#d6d6d6"] CGColor];
        _GuanZLab.userInteractionEnabled = YES;
        [_GuanZLab addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(cancelFollow)]];
    
        //名字
        _nameLab = [TomamaUI createLabel:CGRectMake(0,0,0,0) textAligment:0 font:[UIFont systemFontOfSize:17] textColor:TextBlack text:@""];
        _nameLab.numberOfLines = 0;
        _nameLab.userInteractionEnabled = YES;
        [self.contentView addSubview:_nameLab];
        [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headerImageV.mas_right).offset(10 * screenW_6);
            make.right.equalTo(_GuanZLab.mas_left).offset(-10 * screenW_6);
            make.height.equalTo(@(40 * screenW_6));
            make.top.equalTo(self.contentView).offset(15*screenW_6);
        }];
        
        //画线
        _lineLab = [UILabel new];
        _lineLab.backgroundColor = LineColor;
        _lineLab.text = @" ";
        [self.contentView  addSubview:_lineLab];
        [_lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@0);
            make.right.equalTo(@0);
            make.height.equalTo(@1);
            make.top.equalTo(_headerImageV.mas_bottom).offset(15*screenW_6);
            make.bottom.equalTo(self.contentView).offset(0);
        }];
    }
    
}
//数据加载
-(void)setDataDic:(NSDictionary *)dataDic
{
//    _headerImageV.image = [UIImage imageNamed:@"forumHeader"];
    [_headerImageV sd_setImageWithURL:[NSURL URLWithString:dataDic[@"othersUserheadPortrait"]] placeholderImage:[UIImage imageNamed:@"forumHeader"]];
    self.nameLab.text = [ToolViewVC getNotNullStr:dataDic[@"othersUserNickName"]];//标题
}

-(void)cancelFollow
{
    if (_blcok) {
        _blcok();
    }
}

@end
